time: 2021.3
# -*- coding: utf-8 -*-
# @Time    : 2021/4/1 16:41
# @Author  : luogan
# @Email   : 468640092@qq.com
# @File    : 三乐购物系统作业.py
# @Software: PyCharm.
import sys
#####实现用户登录系统的服务######用到while循环来实现#######
print("欢迎来到王者荣耀，敌军还有三十秒到达战场，碾碎他们！".center(70,"*"))

while True:
    username = input("请选择你的英雄(瑶瑶公主)：")
    passwd   = input("请选择你的皮肤(遇见神鹿)：")
    if username == '瑶瑶公主' and passwd == "遇见神鹿":
        print("选择瑶瑶公主和皮肤成功!游戏即将开始!")
        break
    else:
        print("没有选择瑶瑶公主!请重新选择")
        continue   #登录失败，继续进入循环
##########打印商品列表######字典######
goods_dict ={
"F00001":{"name":"铁剑","price":150},
"F00002":{"name":"泣血之刃","price":1740},
"F00003":{"name":"无尽战刃","price":2140},
"F00004":{"name":"破晓","price":3400},
"F00005":{"name":"痛苦面具","price":2040}}

def goods_info():
    print("-"*20+"商品栏"+"-"*20)  #打印列表标题
    print("商品编号  \t商品  \t商品价格(元)")      #打印商品详细信息
    for i in goods_dict.keys():
        n = goods_dict[i]["name"]
        p = goods_dict[i]["price"]
        print("{}  \t{} \t{}  ".format(i,n,p))
goods_info()

goods_dict2=[]
try:
    # def input_money():
    money = float(input("请问你现在经济多少: "))
    # input_money()
    while True:
            goods_id = input("请输入商品编号:")
            if type(money) == float:
                if goods_dict[f"{goods_id}"]["price"]<=money:
                    print("你已经有经济了，可以适当选择你想购买的装备了!")
                    goods_dict3 = goods_dict[f"{goods_id}"]["name"]
                    buy_goods = goods_dict[f"{goods_id}"]
                    goods_dict2.append(buy_goods)  #购买成功后在篮子里面加入一个购买好的商品编号
                    spend=goods_dict[f"{goods_id}"]["price"]
                    money = money -spend  #买了以后扣掉买东西用的钱
                    print(f"您购买了{goods_dict3},消费了{spend},您的余额还剩{money}")
                    print("================================")
                    for i in goods_dict2:
                        print(i)
                else:
                    print(f"您的余额不足,还剩{money}元,请尽快充值")
                    choice1 = int(input("按1充值，按2退出："))
                    if choice1 ==1:
                        print("我是马画疼，欢迎你来到充值系统".center(50,"&"))
                        add_money = float(input("请输入你要充值的钱："))
                        money = money+add_money
                        print(f"你已经充值成功，充值金额为{add_money},账户余额为{money}")
                    else:
                        choice1 ==2
                        print("你已经退出购物，欢迎下次光临!".center(50,"%"))
                    Q = input("请按Q退出游戏,按任意键继续:")
                    if Q.lower() == "q":
                        sys.exit(0)
            else:

                raise ValueError()
                continue
except Exception:
    print(f"你就告诉我你有多少钱就行，别和我扯那些七七八八的,请重新输入")
    input_money()


######
# i = 0




















